FuncIDataRecord, T c#

54

Func<idatarecord, t=""> c# </idatarecord,> -

public IEnumerable&lt;T&gt; GetData&lt;T&gt;(IDataReader reader, Func&lt;IDataRecord, T&gt; BuildObject)
{
    try
    {
        while (reader.Read())
        {
            yield return BuildObject(reader);
        }
    }
    finally
    {
         reader.Dispose();
    }
}

//call it like this:
var result = GetData(YourLibraryFunction(), Employee.Create);

Comments

Submit
0 Comments